package com.onlyxiahui.framework.net.session;

/**
 *
 * Date 2018-12-30 10:39:59<br>
 * Description
 *
 * @author XiaHui<br>
 * @since 1.0.0
 */
public interface SocketSession {

    /**
     *
     * Date 2018-12-30 11:07:26<br>
     * Description 每个会话的唯一id
     *
     * @author XiaHui<br>
     * @return
     * @since 1.0.0
     */
    public String getId();

    /**
     *
     * Date 2018-12-30 10:40:03<br>
     * Description 设置key，用于身份识别，如将相同的key归入同一个用户
     *
     * @author XiaHui<br>
     * @param key
     * @since 1.0.0
     */
    public void setKey(String key);

    /**
     *
     * Date 2018-12-30 10:40:14<br>
     * Description 获取key
     *
     * @author XiaHui<br>
     * @return
     * @since 1.0.0
     */
    public String getKey();

    /**
     *
     * Date 2018-12-30 10:40:23<br>
     * Description 推送消息
     *
     * @author XiaHui<br>
     * @param object
     * @since 1.0.0
     */
    public void write(Object object);

    /**
     *
     * Date 2018-12-30 10:40:31<br>
     * Description 关闭
     *
     * @author XiaHui<br>
     * @since 1.0.0
     */
    public void close();

    /**
     *
     * Date 2018-12-30 10:40:45<br>
     * Description 添加属性
     *
     * @author XiaHui<br>
     * @param key
     * @param value
     * @since 1.0.0
     */
    public void addAttribute(Object key, Object value);

    /**
     *
     * Date 2018-12-30 10:40:57<br>
     * Description 获取属性
     *
     * @author XiaHui<br>
     * @param <T>
     * @param key
     * @return
     * @since 1.0.0
     */
    public <T> T getAttribute(Object key);

    /**
     *
     * Date 2018-12-30 10:41:08<br>
     * Description 设置是否认证
     *
     * @author XiaHui<br>
     * @param auth
     * @since 1.0.0
     */
    public void setAuth(boolean auth);

    /**
     *
     * Date 2018-12-30 10:41:19<br>
     * Description 是否认证
     *
     * @author XiaHui<br>
     * @return
     * @since 1.0.0
     */
    public boolean isAuth();

    /**
     *
     * Date 2018-12-30 10:41:28<br>
     * Description 获取地址
     *
     * @author XiaHui<br>
     * @return
     * @since 1.0.0
     */
    public String getRemoteAddress();

    /**
     *
     * Date 2018-12-30 11:08:55<br>
     * Description 获取标签
     *
     * @author XiaHui<br>
     * @return
     * @since 1.0.0
     */
    default public String getTag() {
        return "";
    }

    /**
     *
     * Date 2018-12-30 11:08:58<br>
     * Description 设置标签，主要用于将同一用户下，不同平台按不同标签分类
     *
     * @author XiaHui<br>
     * @param tag
     * @since 1.0.0
     */
    public void setTag(String tag);
}
